1 package tw.com.javaworld.CH2;
2
3 import javax.servlet.*;
4 import javax.servlet.http.*;
5 import java.io.*;
6
7 public class Sayhi extends HttpServlet {
8
9 public void init(ServletConfig config) throws ServletException {
11 super.init(config);
12 }
13
14 public void doPost(HttpServletRequest request, HttpServletResponse response)
16 throws ServletException, IOException {
17 response.setContentType("text/html;charset=Big5");
18 PrintWriter out = response.getWriter();
19
20 request.setCharacterEncoding("Big5");
21 String Name = request.getParameter("Name");
22
23 out.println("<html>");
24 out.println("<head><title>CH2 - Sayhi</title></head>");
25 out.println("<body>");
26 out.println("HiĄG"+Name);
27 out.println("</body>");
28 out.println("</html>");
29 out.close();
30 }
31
32 public String getServletInfo() {
34 return "tw.com.javaworld.CH2.Sayhi Information";
35 }
36
37 public void destroy() {
38 }
39}